﻿using CatUtils.Utils.Currency;
using CatUtils.Utils.Currency.IoUtils;
using CatUtilsDll.Utils.Currency.WebUtils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace PixivGifDownLoad.Helper
{
    internal class PixivWebHelper
    {
        public static void FileDownLoad(string FileUrl, DownloadProgressChangedEventHandler DownLoadProgressChanged, AsyncCompletedEventHandler DownloadCompleted)
        {
            WebHeaderCollection webHeader = new WebHeaderCollection();
            webHeader.Add("User-Agent", WebHelper.UserAgentPC);
            webHeader.Add("Referer", "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=" + Path.GetFileNameWithoutExtension(FileUrl));
            string FilePath = PixivStaticValue.TempPath + Path.GetFileName(FileUrl);

            new WebHelper().DownloadToFileAsync(FileUrl, FilePath, webHeader
                , new AsyncCompletedEventHandler(DownloadCompleted), new DownloadProgressChangedEventHandler(DownLoadProgressChanged));
        }
    }
}